﻿using System;
using System.Windows.Input;

namespace MusicPlayer
{

    class InputHandlerKeyboard : ICoreCommands, IPlayListCommands
    {

        public void ProcessKeyPressed(Key keyPressed, int deck)
        {
            switch (keyPressed)
            {
                case Key.Space:
                    {

                        BaseCoreArgs args = new BaseCoreArgs(deck);
                        OnPlay(this, args);

                        break;
                    }
                case Key.P:
                    {
                        BaseCoreArgs args = new BaseCoreArgs(deck);
                        OnPause(this, args);
                        break;
                    }
                case Key.S:
                    {
                        BaseCoreArgs args = new BaseCoreArgs(deck);
                        OnStop(this, args);
                        break;
                    }
                case Key.N:
                    {
                        BaseCoreArgs args = new BaseCoreArgs(deck);
                        OnNext(this, args);
                        break;
                    }
                case Key.B:
                    {
                        BaseCoreArgs args = new BaseCoreArgs(deck);
                        OnPrevious(this, args);
                        break;
                    }
                case Key.M:
                    {
                        BaseCoreArgs args = new BaseCoreArgs(deck);
                        OnMute(this, args);
                        break;
                    }
                case Key.Add:
                    {
                        VolumeChangeEventArgs args = new VolumeChangeEventArgs(deck, 110);
                        OnVolumeChange(this, args);
                        break;
                    }
                case Key.Subtract:
                    {
                        VolumeChangeEventArgs args = new VolumeChangeEventArgs(deck, -10);
                        OnVolumeChange(this, args);
                        break;
                    }
            }
        }
        public void PlaylistKeyPressed(Key keyPressed)
        {
            switch (keyPressed)
            {
                case Key.A:
                    {
                        OnAddFiles(this, new EventArgs());
                        break;
                    }
                case Key.C:
                    {
                        OnClear(this, new EventArgs());
                        break;
                    }
                case Key.Z:
                    {
                        OnSortFiles(this, new EventArgs());
                        break;
                    }
            }
        }

        public void ChangeVolume(double newVolume, int playerIndex)
        {
        }
        public void OrderChange(string newOrder)
        {
        }

        public void CurrentSelectionChange(int currentIndex)
        {
        }

        public void AddFiles()
        {
        }

        public void ClearPlayList()
        {
        }

        public void SortPlayList()
        {           
        }

        //Core specific events
        public event EventHandler<BaseCoreArgs> OnPlay;

        public event EventHandler<BaseCoreArgs> OnPause;

        public event EventHandler<BaseCoreArgs> OnStop;

        public event EventHandler<BaseCoreArgs> OnPrevious;

        public event EventHandler<BaseCoreArgs> OnNext;

        public event EventHandler<VolumeChangeEventArgs> OnVolumeChange;

        public event EventHandler<BaseCoreArgs> OnMute;

        public event EventHandler<PlayerChangeArgs> OnPlayerChange;

        public event EventHandler<DriverChangeArgs> OnDriverChange;
        //PlayList specific events
        public event EventHandler OnAddFiles;

        public event EventHandler OnSortFiles;

        public event EventHandler OnClear;

        public event EventHandler<PlayListOrderArgs> OnOrderChange;

        public event EventHandler<CurrentSongArgs> OnCurrentSongChange;



    }
}
